package
{
	import flash.events.MouseEvent;
	import flash.geom.Point;

	public class MouseDragHelper
	{
		private var m_mouseDown:Boolean = false;
		private var m_mouseDownPosition:Point = new Point(0,0);
		private var m_lastMousePosition:Point = new Point(0,0);
		private var m_isDragging:Boolean = false;
		public var dragVector:Point = new Point(0,0);
		
		public function MouseDragHelper()
		{
		}
		
		public function isDragging():Boolean{
			return m_isDragging;
		}
		
		public function onMouseMove(me:MouseEvent):void{
			var currentMousePosition:Point = new Point(me.stageX, me.stageY);
			dragVector = currentMousePosition.subtract(m_lastMousePosition);
			
			m_isDragging = (dragVector.length > 0) && m_mouseDown;
				
			m_lastMousePosition = currentMousePosition;	
		}
		
		public function onMouseUp(me:MouseEvent):void{
			m_mouseDown = false;
		}
		
		public function onMouseDown(me:MouseEvent):void{
			m_mouseDown = true;
			m_mouseDownPosition = m_lastMousePosition = new Point(me.stageX, me.stageY);			
		}	
		
		public function cleanup():void{}
	}
}